module.exports = app => {
    const { STRING } = app.Sequelize;

    // 默认情况seqyuelize自动将模型名称转为复数(加了一个s)
    const Teacher = app.model.define('teacher', {
        // 自动生成id
        name: STRING,
        subject: STRING,
    })

    // 建立外键
    Teacher.associate = function() {
        app.model.Teacher.belongsTo(app.model.Student, {
            foreignKey: 'student_id',
            as: 'student'
        })
    }


    return Teacher
}